import requests
import xmltodict

def driving_route_planning(TK, orig, dest, style):
    base_url = "http://api.tianditu.gov.cn/drive"
    postStr = """
        {
            \"orig\" : \"%s\",
            \"dest\" : \"%s\",
            \"style\" : \"%s\"
        }
    """ %(orig, dest, style)
    url = f"{base_url}?postStr={postStr}&type=search&tk={TK}"
    url = url.replace("\n", "").replace(" ", "")
    response = requests.get(url)
    result = xmltodict.parse(response.content, encoding='utf-8')["result"]
    distance = result["distance"]
    duration = result["duration"]
    mapinfo = result["mapinfo"]
    routelatlon = result["routelatlon"]
    return distance, duration, mapinfo, routelatlon
